/*
    * @Author Mangodai
    * @Date 8/30/2017 9:32 PM
*/
var flag = false;

function register() {
    // if (confirm(''))
    if (flag == true) {
        $('#msg')[0].innerHTML = '你已经注册过了';
        modalShow();
    } else {
        var jsonData = $("#contact").serializeArray();
        if (jsonData[0].value == "" || jsonData[1].value == "" || jsonData[2].value == "") return;
        $.ajax({
            // url: 'http://219.229.207.48:8080/register/user/register',
            url: 'http://www.zclong.cn/register/user/register',
            type: 'get', //GET
            data: jsonData,
            dataType: "jsonp",
            jsonp: 'callback',
            jsonpCallback: 'callback',
            success: function (data) {
                console.log(data);
                if (data.state == 200) flag = true;
                $('#msg')[0].innerHTML = data.msg + ", 欢迎加入我们的QQ群：" + data.groupMSG;
                modalShow();
            },
            error: function (xhr, textStatus, errorThrown) {
                console.log(xhr);
                console.log(errorThrown);
                console.log(textStatus);
                $('#msg')[0].innerHTML = '链接服务器失败';
                modalShow();
            },
        });
    }
}

function modalShow() {
    $('#msgModal').modal({
        'show': true
    });
}
